/**
 * 判断当前浏览器是移动端还是Web端
 * @returns {Object} 包含设备类型信息的对象
 */
export default function detectDevice() {
    const userAgent = navigator.userAgent || navigator.vendor || window.opera;

    // 移动设备正则表达式
    const mobileRegex = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini|mobile|tablet/i;

    // 具体移动设备类型检测
    const isAndroid = /android/i.test(userAgent);
    const isIOS = /iphone|ipad|ipod/i.test(userAgent);
    const isTablet = /tablet|ipad/i.test(userAgent) ||
        (isAndroid && !/mobile/i.test(userAgent));

    // 判断是否为移动设备
    const isMobile = mobileRegex.test(userAgent);

    return {
        isMobile: isMobile,
        isDesktop: !isMobile,
        isAndroid: isAndroid,
        isIOS: isIOS,
        isTablet: isTablet,
        isPhone: isMobile && !isTablet,
        userAgent: userAgent
    };
}
